package cn.itcast.controller;

import cn.itcast.constant.MessageConstant;
import cn.itcast.entity.Result;
import cn.itcast.pojo.Address;
import cn.itcast.service.CheckAddressService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author coolbook
 * @ClassName AddressController
 * @Description TODO
 * @Date 13:50 2021/11/16
 * @Version 1.0
 */
@RestController
@RequestMapping("address")
@CrossOrigin
public class AddressController {
    @Reference
    private CheckAddressService checkAddressService;

    /**
     * 院区地址
     *
     * @return
     */
    @GetMapping("findAll")
    public Result checkAddress() {

        try {
            List<Address> all = this.checkAddressService.findAll();
            return new Result(true, MessageConstant.QUERY_ADDRESS_SUCCESS, all);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.QUERY_ADDRESS_FAIL);

        }
    }
}
